package service;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SerializerFeature;

import dao.ShiroDao;

/**
 * @author bohan
 * @create 2017年5月21日
 */
public class ShiroServiceImpl implements ShiroService{
	ShiroDao dao;

	public ShiroDao getDao() {
		return dao;
	}

	public void setDao(ShiroDao dao) {
		this.dao = dao;
	}

	@Override
	public String getRoleById(int id) {
		String sql = "select r.role from role_user as ru,role as r where ru.userid='"+id+"' and ru.roleId=r.id";
		List list = new ArrayList();
		list = dao.runsql(sql);
		System.out.println("List:"+list.size());
		JSONArray json = new JSONArray();
		json = JSONArray.parseArray(JSON.toJSONString(list,SerializerFeature.DisableCircularReferenceDetect));
		return json.get(0).toString();
	}
	
}
